package comHttpsession;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(name = "one14Servlet")
public class one14Servlet extends HttpServlet {
    static int money=0;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getParameter("neme");
        request.getParameter("money");
        money+=Integer.valueOf(request.getParameter("money"));
        ServletContext servletContext=request.getServletContext();
        servletContext.setAttribute("money",money);
        HttpSession session=request.getSession();
        Integer i= (Integer) session.getAttribute(request.getParameter("neme"));
        if (i==null)
        {
            session.setAttribute(request.getParameter("neme"),1);
        }
        else
        {
            session.setAttribute(request.getParameter("neme"),i+1);
        }
        response.sendRedirect("/web4/shangping.html");
    }
}
